package com.freewater.springboot.demo.conversion.formatter;

import org.springframework.format.number.CurrencyStyleFormatter;
import org.springframework.format.number.PercentStyleFormatter;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Locale;

public class Main {
    public static void main(String[] args) throws ParseException {
        CurrencyStyleFormatter currencyFormatter = new CurrencyStyleFormatter();
        String printText = currencyFormatter.print(123.123, Locale.US);
        System.out.println(printText);
        final BigDecimal parseVal = currencyFormatter.parse(printText, Locale.US);
        System.out.println(parseVal);

        PercentStyleFormatter percentFormatter = new PercentStyleFormatter();
        printText = percentFormatter.print(0.123, Locale.getDefault());
        System.out.println(printText);

        final Number parseV = percentFormatter.parse(printText, Locale.getDefault());
        System.out.println(parseV);
    }
}
